<?php

namespace app\common\model;

class ProductCategory extends BaseModel
{
    protected $table = 'product_category';

    public static function saveSortNum($sorted_list)
    {
        foreach ($sorted_list as $num => $cate_id){
            self::where('id', $cate_id)->update(['sort' => $num]);
        }
    }
    public static function childList()
    {
        $data = self::order('sort')->select();
        return list2child($data->toArray());
    }
    public static function treeList()
    {
        $data = self::order('sort')->select();
        return list2tree($data->toArray());
    }
}